package com.video.service.impl;

import com.video.dao.SpeakerMapper;
import com.video.entity.Speaker;
import com.video.service.SpeakerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SpeakerServiceImpl implements SpeakerService {

    @Autowired
    public SpeakerMapper speakerMapper;

    @Override
    public List<Speaker> findAll() {
        return speakerMapper.selectByExampleWithBLOBs(null);
    }

    @Override
    public Speaker selectByPrimaryKey(Integer id) {
        return speakerMapper.selectByPrimaryKey(id);
    }


    @Override
    public void addSpeaker(Speaker speaker) {
        speakerMapper.insert(speaker);
    }

    @Override
    public int delSpeakerById(Integer id) {
        return speakerMapper.deleteByPrimaryKey(id);

    }

    @Override
    public int updateById(Integer id) {
        //return speakerMapper.updateByPrimaryKey(id);
        return 0;
    }

    @Override
    public void updateSpeaker(Speaker speaker){
        speakerMapper.updateByPrimaryKeySelective(speaker);
    }

    @Override
    public Integer getTotalCount() {
        return speakerMapper.getTotalCount();
    }

    @Override
    public Speaker findById(Integer id) {
        return speakerMapper.selectByPrimaryKey(id);
    }

    @Override
    public Integer deleteById(Integer id) {
        return speakerMapper.deleteByPrimaryKey(id);
    }
}
